<?php
namespace Admin\Controller;
use Common\Controller\CommonController;
class IndexController extends CommonController {
    public function index(){
    	$model = M("booking");
		if(isset($_GET["meals_id"])) {
			if($_GET["meals_id"] == 1) {
				$sql = " AND (booking.breakfast = " . I("get.meals_id") . " AND booking.lunch = 0)";
			}elseif($_GET["meals_id"] == 0) {
				$sql = " AND (booking.breakfast = " . I("get.meals_id") . " AND booking.lunch = 1)";
			}else {
				$sql = "";
			}
		}else {
			$sql = "";
		}
  		$data = $model->field("booking.*, user.name, user.tobelongto")->join("LEFT JOIN user ON booking.user_id = user.id")->where("TO_DAYS(timestamp)=TO_DAYS(NOW())".$sql)->order("id")->select();
//  	echo $model->getLastSql();
		$this->assign("total",count($data));
		$this->assign("data",$data);
        $this->display();
    }
}